<template>
  <div class="risk-assessment">
    <!-- 页面头部 -->
    <div class="page-header">
      <h1>诈骗风险评估</h1>
      <p>全面评估潜在诈骗风险，提供个性化防护建议</p>
    </div>

    <!-- 评估流程指示 -->
    <div class="assessment-steps">
      <div class="step-item" :class="{ active: currentStep === 1, completed: currentStep > 1 }">
        <div class="step-number">1</div>
        <div class="step-title">基本信息</div>
      </div>
      <div class="step-line"></div>
      <div class="step-item" :class="{ active: currentStep === 2, completed: currentStep > 2 }">
        <div class="step-number">2</div>
        <div class="step-title">风险因素</div>
      </div>
      <div class="step-line"></div>
      <div class="step-item" :class="{ active: currentStep === 3, completed: currentStep > 3 }">
        <div class="step-number">3</div>
        <div class="step-title">详细评估</div>
      </div>
      <div class="step-line"></div>
      <div class="step-item" :class="{ active: currentStep === 4, completed: currentStep > 4 }">
        <div class="step-number">4</div>
        <div class="step-title">结果分析</div>
      </div>
    </div>

    <!-- 评估表单 -->
    <div class="assessment-form">
      <!-- 第一步：基本信息 -->
      <div v-show="currentStep === 1" class="step-content">
        <h3>基本信息</h3>
        <div class="form-grid">
          <div class="form-group">
            <label>情况类型</label>
            <select v-model="formData.situationType">
              <option value="">请选择</option>
              <option value="phone">可疑电话</option>
              <option value="sms">可疑短信</option>
              <option value="email">可疑邮件</option>
              <option value="website">可疑网站</option>
              <option value="investment">投资机会</option>
              <option value="other">其他</option>
            </select>
          </div>

          <div class="form-group">
            <label>紧急程度</label>
            <div class="radio-group">
              <label><input type="radio" v-model="formData.urgency" value="high"> 紧急</label>
              <label><input type="radio" v-model="formData.urgency" value="medium"> 一般</label>
              <label><input type="radio" v-model="formData.urgency" value="low"> 不紧急</label>
            </div>
          </div>

          <div class="form-group">
            <label>涉及金额</label>
            <input type="number" v-model="formData.amount" placeholder="请输入金额">
          </div>

          <div class="form-group">
            <label>发生时间</label>
            <input type="datetime-local" v-model="formData.occurTime">
          </div>
        </div>

        <div class="form-group">
          <label>详细描述</label>
          <textarea v-model="formData.description" placeholder="请详细描述遇到的情况..." rows="4"></textarea>
        </div>
      </div>

      <!-- 第二步：风险因素 -->
      <div v-show="currentStep === 2" class="step-content">
        <h3>风险因素识别</h3>
        <div class="risk-factors">
          <div v-for="factor in riskFactors" :key="factor.id" class="factor-item">
            <div class="factor-header">
              <h4>{{ factor.title }}</h4>
              <div class="factor-score">{{ factor.score }}/10</div>
            </div>
            <div class="factor-questions">
              <div v-for="question in factor.questions" :key="question.id" class="question-item">
                <div class="question-text">{{ question.text }}</div>
                <div class="question-options">
                  <label v-for="option in question.options" :key="option.value">
                    <input type="radio" :name="question.id" :value="option.value" @change="updateFactorScore(factor.id, question.id, option.value)">
                    {{ option.label }}
                  </label>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 第三步：详细评估 -->
      <div v-show="currentStep === 3" class="step-content">
        <h3>详细评估</h3>
        <div class="detailed-assessment">
          <div class="assessment-section">
            <h4>通信信息验证</h4>
            <div class="form-grid">
              <div class="form-group">
                <label>联系方式</label>
                <input type="text" v-model="formData.contactInfo" placeholder="电话号码/邮箱地址">
              </div>
              <div class="form-group">
                <label>验证状态</label>
                <div class="verification-status">
                  <button @click="verifyContact" :disabled="!formData.contactInfo" class="verify-btn">
                    验证
                  </button>
                  <span v-if="contactVerification" :class="contactVerification.status">
                    {{ contactVerification.message }}
                  </span>
                </div>
              </div>
            </div>
          </div>

          <div class="assessment-section">
            <h4>行为模式分析</h4>
            <div class="behavior-checklist">
              <div v-for="behavior in behaviorChecklist" :key="behavior.id" class="behavior-item">
                <label>
                  <input type="checkbox" v-model="behavior.checked" @change="updateBehaviorScore">
                  {{ behavior.text }}
                </label>
                <div class="behavior-weight">+{{ behavior.weight }}</div>
              </div>
            </div>
          </div>

          <div class="assessment-section">
            <h4>环境因素</h4>
            <div class="form-grid">
              <div class="form-group">
                <label>接触渠道</label>
                <select v-model="formData.channel">
                  <option value="">请选择</option>
                  <option value="phone">电话</option>
                  <option value="sms">短信</option>
                  <option value="email">邮件</option>
                  <option value="social">社交媒体</option>
                  <option value="website">网站</option>
                  <option value="person">面对面</option>
                </select>
              </div>
              <div class="form-group">
                <label>信息来源</label>
                <input type="text" v-model="formData.source" placeholder="信息来源">
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 第四步：结果分析 -->
      <div v-show="currentStep === 4" class="step-content">
        <h3>风险评估结果</h3>
        <div class="assessment-result">
          <div class="result-overview">
            <div class="risk-score">
              <div class="score-circle" :class="getRiskClass(totalRiskScore)">
                <div class="score-value">{{ totalRiskScore }}</div>
                <div class="score-label">风险指数</div>
              </div>
            </div>
            <div class="risk-info">
              <div class="risk-level" :class="getRiskClass(totalRiskScore)">
                {{ getRiskLevel(totalRiskScore) }}风险
              </div>
              <div class="risk-description">
                {{ getRiskDescription(totalRiskScore) }}
              </div>
            </div>
          </div>

          <div class="score-breakdown">
            <h4>风险分解</h4>
            <div class="breakdown-items">
              <div v-for="item in scoreBreakdown" :key="item.name" class="breakdown-item">
                <div class="item-name">{{ item.name }}</div>
                <div class="item-bar">
                  <div class="bar-fill" :style="{ width: (item.score / 10) * 100 + '%' }"></div>
                </div>
                <div class="item-score">{{ item.score }}/10</div>
              </div>
            </div>
          </div>

          <div class="recommendations">
            <h4>防护建议</h4>
            <div class="recommendation-list">
              <div v-for="rec in recommendations" :key="rec.id" class="recommendation-item">
                <div class="rec-priority" :class="rec.priority">{{ rec.priority }}</div>
                <div class="rec-content">
                  <h5>{{ rec.title }}</h5>
                  <p>{{ rec.description }}</p>
                </div>
              </div>
            </div>
          </div>

          <div class="action-plan">
            <h4>行动计划</h4>
            <div class="plan-steps">
              <div v-for="step in actionPlan" :key="step.id" class="plan-step">
                <div class="step-icon">{{ step.icon }}</div>
                <div class="step-content">
                  <h5>{{ step.title }}</h5>
                  <p>{{ step.description }}</p>
                </div>
                <div class="step-action">
                  <button @click="executeAction(step)" class="action-btn">执行</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 导航按钮 -->
    <div class="navigation-buttons">
      <button v-if="currentStep > 1" @click="previousStep" class="nav-btn secondary">上一步</button>
      <button v-if="currentStep < 4" @click="nextStep" :disabled="!canProceed" class="nav-btn primary">下一步</button>
      <button v-if="currentStep === 4" @click="saveAssessment" class="nav-btn primary">保存评估</button>
    </div>

    <!-- 实时风险监控 -->
    <div class="real-time-monitor">
      <h3>实时风险监控</h3>
      <div class="monitor-grid">
        <div class="monitor-card">
          <h4>当前风险等级</h4>
          <div class="risk-gauge">
            <div class="gauge-bg">
              <div class="gauge-fill" :style="{ transform: `rotate(${(totalRiskScore / 100) * 180}deg)` }"></div>
            </div>
            <div class="gauge-value">{{ totalRiskScore }}%</div>
          </div>
        </div>
        
        <div class="monitor-card">
          <h4>风险趋势</h4>
          <div class="trend-chart">
            <canvas ref="trendChart" width="300" height="150"></canvas>
          </div>
        </div>
        
        <div class="monitor-card">
          <h4>相似案例</h4>
          <div class="similar-cases">
            <div v-for="case_ in similarCases" :key="case_.id" class="case-item">
              <div class="case-similarity">{{ case_.similarity }}%</div>
              <div class="case-info">
                <h5>{{ case_.title }}</h5>
                <p>{{ case_.description }}</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'

// 响应式数据
const currentStep = ref(1)
const totalRiskScore = ref(0)
const contactVerification = ref(null)

// 表单数据
const formData = ref({
  situationType: '',
  urgency: '',
  amount: '',
  occurTime: '',
  description: '',
  contactInfo: '',
  channel: '',
  source: ''
})

// 风险因素
const riskFactors = ref([
  {
    id: 1,
    title: '身份验证',
    score: 0,
    questions: [
      {
        id: 'q1',
        text: '对方是否主动联系您？',
        options: [
          { value: 5, label: '是' },
          { value: 0, label: '否' }
        ]
      },
      {
        id: 'q2',
        text: '对方是否声称来自官方机构？',
        options: [
          { value: 3, label: '是' },
          { value: 0, label: '否' }
        ]
      }
    ]
  },
  {
    id: 2,
    title: '金钱要求',
    score: 0,
    questions: [
      {
        id: 'q3',
        text: '是否要求立即转账或付款？',
        options: [
          { value: 8, label: '是' },
          { value: 0, label: '否' }
        ]
      },
      {
        id: 'q4',
        text: '是否承诺高额回报？',
        options: [
          { value: 6, label: '是' },
          { value: 0, label: '否' }
        ]
      }
    ]
  },
  {
    id: 3,
    title: '时间压力',
    score: 0,
    questions: [
      {
        id: 'q5',
        text: '是否强调时间紧迫？',
        options: [
          { value: 4, label: '是' },
          { value: 0, label: '否' }
        ]
      },
      {
        id: 'q6',
        text: '是否不允许您考虑时间？',
        options: [
          { value: 5, label: '是' },
          { value: 0, label: '否' }
        ]
      }
    ]
  }
])

// 行为检查清单
const behaviorChecklist = ref([
  { id: 1, text: '要求提供个人敏感信息', checked: false, weight: 15 },
  { id: 2, text: '拒绝提供官方联系方式', checked: false, weight: 10 },
  { id: 3, text: '使用威胁或恐吓语言', checked: false, weight: 12 },
  { id: 4, text: '要求保密不告诉他人', checked: false, weight: 8 },
  { id: 5, text: '联系方式异常或隐蔽', checked: false, weight: 7 },
  { id: 6, text: '语言表达不专业', checked: false, weight: 5 }
])

// 相似案例
const similarCases = ref([
  {
    id: 1,
    similarity: 85,
    title: '冒充银行客服诈骗',
    description: '声称账户异常，要求提供验证码'
  },
  {
    id: 2,
    similarity: 72,
    title: '虚假投资理财',
    description: '承诺高收益，要求先缴纳手续费'
  },
  {
    id: 3,
    similarity: 68,
    title: '网络购物诈骗',
    description: '低价商品诱导，要求预付定金'
  }
])

// 计算属性
const canProceed = computed(() => {
  switch (currentStep.value) {
    case 1:
      return formData.value.situationType && formData.value.urgency && formData.value.description
    case 2:
      return riskFactors.value.every(factor => factor.score > 0)
    case 3:
      return formData.value.channel
    default:
      return true
  }
})

const scoreBreakdown = computed(() => {
  const factorScores = riskFactors.value.map(factor => ({
    name: factor.title,
    score: factor.score
  }))
  
  const behaviorScore = behaviorChecklist.value
    .filter(item => item.checked)
    .reduce((sum, item) => sum + item.weight, 0)
  
  return [
    ...factorScores,
    { name: '行为模式', score: Math.min(behaviorScore / 10, 10) }
  ]
})

const recommendations = computed(() => {
  const recs = []
  
  if (totalRiskScore.value >= 70) {
    recs.push({
      id: 1,
      priority: '紧急',
      title: '立即停止所有操作',
      description: '请立即停止与对方的所有交流和操作，避免进一步损失'
    })
  }
  
  if (totalRiskScore.value >= 50) {
    recs.push({
      id: 2,
      priority: '重要',
      title: '联系官方机构核实',
      description: '通过官方渠道联系相关机构，核实信息真实性'
    })
  }
  
  recs.push({
    id: 3,
    priority: '建议',
    title: '加强个人信息保护',
    description: '提高个人信息保护意识，不轻易透露敏感信息'
  })
  
  return recs
})

const actionPlan = computed(() => {
  const plan = []
  
  if (totalRiskScore.value >= 70) {
    plan.push({
      id: 1,
      icon: '🚨',
      title: '紧急报警',
      description: '立即拨打110或相关部门举报电话',
      action: 'emergency'
    })
  }
  
  plan.push({
    id: 2,
    icon: '📞',
    title: '官方核实',
    description: '通过官方渠道核实相关信息',
    action: 'verify'
  })
  
  plan.push({
    id: 3,
    icon: '🔒',
    title: '账户安全',
    description: '检查并加强账户安全设置',
    action: 'secure'
  })
  
  return plan
})

// 方法
const nextStep = () => {
  if (currentStep.value < 4) {
    currentStep.value++
    if (currentStep.value === 4) {
      calculateRiskScore()
    }
  }
}

const previousStep = () => {
  if (currentStep.value > 1) {
    currentStep.value--
  }
}

const updateFactorScore = (factorId, questionId, value) => {
  const factor = riskFactors.value.find(f => f.id === factorId)
  if (factor) {
    // 简单的评分逻辑
    factor.score = Math.min(factor.score + value, 10)
  }
}

const updateBehaviorScore = () => {
  calculateRiskScore()
}

const calculateRiskScore = () => {
  const factorTotal = riskFactors.value.reduce((sum, factor) => sum + factor.score, 0)
  const behaviorTotal = behaviorChecklist.value
    .filter(item => item.checked)
    .reduce((sum, item) => sum + item.weight, 0)
  
  totalRiskScore.value = Math.min(factorTotal * 2 + behaviorTotal, 100)
}

const verifyContact = () => {
  // 模拟验证逻辑
  setTimeout(() => {
    const random = Math.random()
    if (random > 0.7) {
      contactVerification.value = {
        status: 'verified',
        message: '验证通过，信息可信'
      }
    } else if (random > 0.3) {
      contactVerification.value = {
        status: 'suspicious',
        message: '存在异常，建议谨慎处理'
      }
    } else {
      contactVerification.value = {
        status: 'dangerous',
        message: '高风险，建议避免接触'
      }
    }
  }, 1000)
}

const getRiskClass = (score) => {
  if (score >= 70) return 'high'
  if (score >= 40) return 'medium'
  return 'low'
}

const getRiskLevel = (score) => {
  if (score >= 70) return '高'
  if (score >= 40) return '中'
  return '低'
}

const getRiskDescription = (score) => {
  if (score >= 70) return '存在严重诈骗风险，建议立即停止相关操作'
  if (score >= 40) return '存在一定风险，建议谨慎处理并多方核实'
  return '风险相对较低，但仍需保持警惕'
}

const saveAssessment = () => {
  console.log('保存评估结果')
  // 保存评估结果到后端
}

const executeAction = (step) => {
  console.log('执行行动:', step.action)
  // 执行具体行动
}

onMounted(() => {
  // 初始化图表
  drawTrendChart()
})

const drawTrendChart = () => {
  const canvas = document.querySelector('#trendChart')
  if (!canvas) return
  
  const ctx = canvas.getContext('2d')
  
  // 绘制趋势线
  ctx.beginPath()
  ctx.strokeStyle = '#ff9800'
  ctx.lineWidth = 2
  
  const points = [
    { x: 30, y: 100 },
    { x: 80, y: 90 },
    { x: 130, y: 80 },
    { x: 180, y: 85 },
    { x: 230, y: 75 },
    { x: 280, y: 70 }
  ]
  
  points.forEach((point, index) => {
    if (index === 0) {
      ctx.moveTo(point.x, point.y)
    } else {
      ctx.lineTo(point.x, point.y)
    }
  })
  
  ctx.stroke()
}
</script>

<style scoped>
.risk-assessment {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.page-header {
  text-align: center;
  margin-bottom: 30px;
}

.page-header h1 {
  color: #1e3c72;
  margin-bottom: 10px;
}

.page-header p {
  color: #666;
  font-size: 16px;
}

.assessment-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 30px;
  background: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f0f0f0;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-bottom: 10px;
}

.step-item.active .step-number {
  background: #1e3c72;
  color: white;
}

.step-item.completed .step-number {
  background: #4caf50;
  color: white;
}

.step-title {
  font-size: 14px;
  color: #666;
  text-align: center;
}

.step-item.active .step-title {
  color: #1e3c72;
  font-weight: bold;
}

.step-line {
  width: 100px;
  height: 2px;
  background: #f0f0f0;
  margin: 0 10px;
}

.assessment-form {
  background: white;
  border-radius: 10px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  min-height: 400px;
}

.step-content h3 {
  color: #1e3c72;
  margin-bottom: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-weight: 600;
  color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.radio-group {
  display: flex;
  gap: 20px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: normal;
}

.risk-factors {
  display: grid;
  gap: 20px;
}

.factor-item {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 20px;
  border-left: 4px solid #1e3c72;
}

.factor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.factor-header h4 {
  color: #333;
  margin: 0;
}

.factor-score {
  background: #1e3c72;
  color: white;
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: bold;
}

.factor-questions {
  display: grid;
  gap: 15px;
}

.question-item {
  background: white;
  border-radius: 5px;
  padding: 15px;
}

.question-text {
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.question-options {
  display: flex;
  gap: 20px;
}

.question-options label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: normal;
}

.detailed-assessment {
  display: grid;
  gap: 30px;
}

.assessment-section {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 20px;
}

.assessment-section h4 {
  color: #1e3c72;
  margin-bottom: 15px;
}

.verification-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.verify-btn {
  background: #1e3c72;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.verify-btn:hover:not(:disabled) {
  background: #2a5298;
}

.verify-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.verification-status .verified {
  color: #4caf50;
  font-weight: bold;
}

.verification-status .suspicious {
  color: #ff9800;
  font-weight: bold;
}

.verification-status .dangerous {
  color: #f44336;
  font-weight: bold;
}

.behavior-checklist {
  display: grid;
  gap: 10px;
}

.behavior-item {
  background: white;
  border-radius: 5px;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.behavior-item label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: normal;
}

.behavior-weight {
  font-weight: bold;
  color: #ff9800;
}

.assessment-result {
  display: grid;
  gap: 30px;
}

.result-overview {
  display: flex;
  align-items: center;
  gap: 30px;
  background: #f8f9ff;
  border-radius: 10px;
  padding: 30px;
}

.risk-score {
  flex-shrink: 0;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  position: relative;
}

.score-circle.high {
  background: linear-gradient(135deg, #f44336, #ff5722);
  color: white;
}

.score-circle.medium {
  background: linear-gradient(135deg, #ff9800, #ffc107);
  color: white;
}

.score-circle.low {
  background: linear-gradient(135deg, #4caf50, #8bc34a);
  color: white;
}

.score-value {
  font-size: 36px;
  font-weight: bold;
}

.score-label {
  font-size: 14px;
  opacity: 0.8;
}

.risk-info {
  flex: 1;
}

.risk-level {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 10px;
}

.risk-level.high {
  color: #f44336;
}

.risk-level.medium {
  color: #ff9800;
}

.risk-level.low {
  color: #4caf50;
}

.risk-description {
  font-size: 16px;
  color: #666;
  line-height: 1.5;
}

.score-breakdown {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.score-breakdown h4 {
  color: #1e3c72;
  margin-bottom: 15px;
}

.breakdown-items {
  display: grid;
  gap: 15px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.item-name {
  min-width: 100px;
  font-weight: 600;
  color: #333;
}

.item-bar {
  flex: 1;
  height: 20px;
  background: #f0f0f0;
  border-radius: 10px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1e3c72, #2a5298);
  transition: width 0.3s ease;
}

.item-score {
  font-weight: bold;
  color: #1e3c72;
}

.recommendations {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.recommendations h4 {
  color: #1e3c72;
  margin-bottom: 15px;
}

.recommendation-list {
  display: grid;
  gap: 15px;
}

.recommendation-item {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  align-items: flex-start;
  gap: 15px;
}

.rec-priority {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
}

.rec-priority.紧急 {
  background: #ffebee;
  color: #f44336;
}

.rec-priority.重要 {
  background: #fff3e0;
  color: #ff9800;
}

.rec-priority.建议 {
  background: #e8f5e8;
  color: #4caf50;
}

.rec-content h5 {
  color: #333;
  margin: 0 0 5px 0;
}

.rec-content p {
  color: #666;
  margin: 0;
  font-size: 14px;
}

.action-plan {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.action-plan h4 {
  color: #1e3c72;
  margin-bottom: 15px;
}

.plan-steps {
  display: grid;
  gap: 15px;
}

.plan-step {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.step-icon {
  font-size: 24px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.step-content {
  flex: 1;
}

.step-content h5 {
  color: #333;
  margin: 0 0 5px 0;
}

.step-content p {
  color: #666;
  margin: 0;
  font-size: 14px;
}

.step-action {
  flex-shrink: 0;
}

.action-btn {
  background: #1e3c72;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.action-btn:hover {
  background: #2a5298;
}

.navigation-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 30px;
}

.nav-btn {
  padding: 12px 30px;
  border: none;
  border-radius: 25px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav-btn.primary {
  background: #1e3c72;
  color: white;
}

.nav-btn.primary:hover:not(:disabled) {
  background: #2a5298;
  transform: translateY(-2px);
}

.nav-btn.secondary {
  background: #f5f5f5;
  color: #666;
  border: 1px solid #ddd;
}

.nav-btn.secondary:hover {
  background: #e8e8e8;
}

.nav-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.real-time-monitor {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.real-time-monitor h3 {
  color: #1e3c72;
  margin-bottom: 20px;
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.monitor-card {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 20px;
}

.monitor-card h4 {
  color: #333;
  margin-bottom: 15px;
}

.risk-gauge {
  position: relative;
  width: 150px;
  height: 75px;
  margin: 20px auto;
}

.gauge-bg {
  width: 100%;
  height: 100%;
  background: conic-gradient(from 180deg, #4caf50 0deg, #ff9800 90deg, #f44336 180deg);
  border-radius: 75px 75px 0 0;
  position: relative;
  overflow: hidden;
}

.gauge-bg::after {
  content: '';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 0;
  background: white;
  border-radius: 65px 65px 0 0;
}

.gauge-fill {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 60px;
  background: #333;
  transform-origin: bottom;
  z-index: 10;
}

.gauge-value {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.trend-chart {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 150px;
}

.similar-cases {
  display: grid;
  gap: 10px;
}

.case-item {
  background: white;
  border-radius: 5px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.case-similarity {
  font-size: 12px;
  font-weight: bold;
  color: #1e3c72;
  min-width: 40px;
}

.case-info h5 {
  color: #333;
  margin: 0 0 2px 0;
  font-size: 14px;
}

.case-info p {
  color: #666;
  margin: 0;
  font-size: 12px;
}

@media (max-width: 768px) {
  .risk-assessment {
    padding: 10px;
  }
  
  .assessment-steps {
    flex-direction: column;
    gap: 10px;
  }
  
  .step-line {
    width: 2px;
    height: 20px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .result-overview {
    flex-direction: column;
    text-align: center;
  }
  
  .monitor-grid {
    grid-template-columns: 1fr;
  }
}
</style> 